package oop2.exer2;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Bank
 * Package: oop2.exer2
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-21
 * Time: 16:05
 */

//银行类
public class Bank {

    //用于存储多个客户
    private Customer[] customers;

    //用于记录存储的客户的个数
    private int numberOfCustomer;
    //就是初始化数组的长度是10 但是客户只有3个


    public Bank() {
        customers = new Customer[10];

    }

    //将指定姓名的客户保存在银行的客户列表中
    public void addCustomer(String f, String l) {
        Customer customer = new Customer(f, l);
        customers[numberOfCustomer] = customer;
        numberOfCustomer++;
    }

    //获取客户列表的个数
    public int getNumberOfCustomer() {
        return numberOfCustomer;
    }

    //获取指定索引位置上的客户
    public Customer getCustomer(int index) {
        if (index < 0 || index >= numberOfCustomer) {
            return null;
        }

        return customers[index];
    }

}
